package com.admin.kotlintest

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.admin.kotlintest.adapter.ListTAdapter
import kotlinx.android.synthetic.main.activity_listview.*

/**
 * Created by 吴昶 on 2018/3/28.
 */
class ListviewActivity: AppCompatActivity() {

    private var listarray:Array<String>?=null
    private var data = ArrayList<String>()
    private var adapter:ListTAdapter?=null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_listview)
        listarray=resources.getStringArray(R.array.list_text)
        //循环读取数组的内容 listarray!! 表示判空
        (0 until listarray!!.count()).forEach {
            data.add(listarray!![it])
        }
        adapter=ListTAdapter(this,R.layout.layout_list_item,data)
        lv_1.adapter=adapter
    }
}